package web.testcase;

import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import org.junit.jupiter.params.provider.ValueSource;
import web.page.ContactPage;
import web.page.WeWork;

import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.MatcherAssert.assertThat;

public class MemberTest0417 {

    /**
     * 1.实现部门的管理
     * 2.成员的管理，丰富下测试用例，加上上传功能
     * 3.标签的管理
     * 4.参数化用例
     */

    @ParameterizedTest
    @ValueSource(strings = {"测试部门","开发部门"})
    void addDepartment(String deptName){
        ContactPage contactPage=new WeWork().startWeb().login().toContactPage();
        contactPage.addDepartment(deptName);
        contactPage.searchDept(deptName);
        assertThat(contactPage.searchDeptResult(),containsString(deptName));
    }

    @ParameterizedTest
    @ValueSource(strings = {"henry"})
    void importMember(String mbrName) throws InterruptedException {
        ContactPage contactPage=new WeWork().startWeb().login().toContactPage();
        String rootPath=this.getClass().getResource("/").getPath().substring(1);
        contactPage.importMember(rootPath+"file/抹茶昕球通讯录.xlsx");
        Thread.sleep(3000);
        contactPage.searchDept(mbrName);
        assertThat(contactPage.searchMbrResult(),containsString(mbrName));
    }

    @ParameterizedTest
    @CsvSource({
            "测试项目,所有管理员"
    })
    void addTag(String tagName,String deptName) throws InterruptedException {
        ContactPage contactPage=new WeWork().startWeb().login().toContactPage();
        contactPage.addTag(tagName,deptName);
        contactPage.searchTag(tagName);
        assertThat(contactPage.searchTagResult(),containsString(tagName));
    }
}